#pragma once
#include <cmath>
#define pi acos(-1)
//This is a function repository with the functions on the handouts.
//B
double Bfunc1(double x)
{
	return pow(x, -1) - tan(x);
}

double Bfunc2(double x)
{
	return pow(x, -1) - pow(2, x);
}

double Bfunc3(double x)
{
	return pow(2, -x) + exp(x) + 2 * cos(x) - 6;
}

double Bfunc4(double x)
{
	return (pow(x, 3) + 4 * pow(x, 2) + 3 * x + 5) / (2 * pow(x, 3) - 9 * pow(x, 2) + 18 * x - 2);
}
//C
double Cfunc1(double x)
{
	return x - tan(x);
}
double Cdfunc1(double x)
{
	return 1.0 - pow(cos(x), -2);
}
//D
double Dfunc1(double x)
{
	return sin(x / 2.0) - 1;
}
double Dfunc2(double x)
{
	return exp(x) - tan(x);
}
double Dfunc3(double x)
{
	return pow(x, 3) - 12 * pow(x, 2) + 3 * x + 1;
}
//E water tank question
//The depth of water is depth := r - h
double Tankquestion(double depth)
{
	double L = 10.0, r = 1.0, V = 12.4; //constants
	return L * (0.5 * pi * pow(r, 2) - pow(r, 2) * asin((r - depth) / r) \
		- (r - depth) * pow((pow(r, 2) - pow((r - depth), 2)), 0.5)) - V;
}
double dTankquestion(double depth)
{
	double L = 10.0, r = 1.0;
	return 2 * L * pow((2 * r - depth) * depth, 0.5);
}